// Copyright 2015-2023 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// mqbnet_negotiator.h                                                -*-C++-*-
#ifndef INCLUDED_MQBNET_NEGOTIATOR
#define INCLUDED_MQBNET_NEGOTIATOR

//@PURPOSE: Provide a protocol for a session negotiator.
//
//@CLASSES:
//  mqbnet::Negotiator: protocol for a session negotiator
//
//@SEE_ALSO:
//  mqbnet::Session: protocol of the negotiated sessions
//
//@DESCRIPTION: 'mqbnet::Negotiator' is a protocol for a session negotiator
// that uses a provided established channel to negotiate and create an
// 'mqbnet::Session' object.
//

// BDE
#include <bsl_memory.h>
#include <bsl_ostream.h>

namespace BloombergLP {

namespace mqbnet {

// FORWARD DECLARATION
class Session;
class InitialConnectionContext;

// ================
// class Negotiator
// ================

/// Protocol for a session negotiator.
class Negotiator {
  public:
    // CREATORS

    /// Destructor
    virtual ~Negotiator();

    // MANIPULATORS

    /// Create a `session` based on the type of NegotiationMessage in
    /// the specified `context`.  Return 0 on success, or a non-zero error code
    /// and populate the specified `errorDescription` with a description of the
    /// error otherwise.
    virtual int
    createSessionOnMsgType(bsl::ostream&                     errorDescription,
                           bsl::shared_ptr<mqbnet::Session>* session,
                           InitialConnectionContext*         context) = 0;

    /// Send out outbound negotiation message with the specified `context`.
    /// Return 0 on success, or a non-zero error code and populate the
    /// specified `errorDescription` with a description of the error otherwise.
    virtual int negotiateOutbound(
        bsl::ostream&                                    errorDescription,
        const bsl::shared_ptr<InitialConnectionContext>& context) = 0;
};

}  // close package namespace
}  // close enterprise namespace

#endif
